<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
    <title>Document</title>
    <style>
        #fa{
            width: 600px;
            height: 600px;
            border:1px solid red;
        }
        #fa>div{
            width: 33%;
            height: 33%;
            border: 1px solid red;
            float: left;
            line-height: 200px;
            text-align: center;
            font-size: 30px;
            font-weight: bold;
        }
        #start{
            cursor: pointer;
            background-color: pink;
        }
    </style>
</head>
<body>
    <div id="fa">
        <div class="option">iphone1</div>
        <div class="option">iphone2</div>
        <div class="option">iphone3</div>
        <div class="option">iphone4</div>
        <div id="start">开始抽奖</div>
        <div class="option">iphone5</div>
        <div class="option">iphone6</div>
        <div class="option">iphone7</div>
        <div class="option">iphone8</div>
    </div>

    <script>
        function getNum(num) {
            if(num * num * num > 5000)
                return 5000;
            return num*num*num;
        }
        let timer = null;
        $('#start').click(function() {
            let options = $('.option');
            let ran = Math.round(Math.random()*(30-0)+20);
            console.log(ran);
            for (let num = 0; num < ran; ++num) {
                setTimeout(()=>{
                    console.log(num)
                    options[num % 8].style.background = 'orange';
                    options[(num +7) % 8].style.background = '#fff';  
                }, getNum(num));
            } 
        });
    </script>
</body>
</html>